package com.syni.mdd.sjb.common.datatreaure.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.syni.mdd.sjb.common.component.mybatis.dxshapp.entity.DxshAppIndustry;
import com.syni.mdd.sjb.common.component.mybatis.dxshapp.entity.DxshAppIndustryChoose;
import com.syni.mdd.sjb.common.component.mybatis.dxshapp.mapper.DxshAppIndustryChooseMapper;
import com.syni.mdd.sjb.common.datatreaure.service.DxshAppIndustryChooseService;
import com.syni.mdd.sjb.common.datatreaure.service.DxshAppIndustryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lcc
 * @since 2020-09-17
 */
@Service
public class DxshAppIndustryChooseServiceImpl extends ServiceImpl<DxshAppIndustryChooseMapper, DxshAppIndustryChoose> implements DxshAppIndustryChooseService {
    @Autowired
    DxshAppIndustryChooseMapper dxshAppIndustryChooseMapper;

    @Autowired
    DxshAppIndustryService dxshAppIndustryService;

    @Override
    public boolean isUserChooseInDustry(Integer userId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq(DxshAppIndustryChoose.USER_ID,userId);
        return dxshAppIndustryChooseMapper.selectCount(queryWrapper) > 0;
    }

    @Override
    public DxshAppIndustry getUserChooseInIndustry(Integer userId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq(DxshAppIndustryChoose.USER_ID,userId);
        DxshAppIndustryChoose dxshAppIndustryChoose = dxshAppIndustryChooseMapper.selectOne(queryWrapper);
        if(dxshAppIndustryChoose != null){
            DxshAppIndustry dxshAppIndustry = dxshAppIndustryService.getById(dxshAppIndustryChoose.getIndustryId());
            return dxshAppIndustry;
        }
        return null;
    }
}
